package leetcode306周赛;
/**
 * 动态规划
 * 
 * @author I adore you
 *
 */
public class Four {

//	static char [] std = {'0','1','2','3','4','5','6','7','8','9'}; 

	public static void main(String []args) {
		int n = 135;
		int res = new Four().recursion(n);
		System.out.println(res);
	}
	
	
	public int recursion(int n) {
//		int ans = 0;
		if(n < 10)
			return n;
		
		return  (judge(n + "") ? 1 : 0) + recursion(n - 1 );
//		return ans;
	}
	public boolean judge(String s) {
		int [] std = new int[10];
		for(char i : s.toCharArray()) {
			if(std[i - '0'] != 0)
				return false;
			std[i - '0']++;
		
		}
		return true;
	}
	
}
